package com.atguigu.gulimall.product.entity;

import com.atguigu.common.vilid.AddGroup;
import com.atguigu.common.vilid.UpdateGroup;
import com.atguigu.common.vilid.UpdateStatusGroup;
import com.atguigu.common.vilid.myAnnotations.ListValue;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * 品牌
 * 
 * @author yuwenyi
 * @email 1171370471@qq.com
 * @date 2021-05-25 22:31:54
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@TableId
	@NotNull(message = "修改品牌信息必须携带品牌id",groups = UpdateGroup.class)
	@Null(message = "新增品牌信息不能携带品牌id",groups = AddGroup.class)
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名不能为空",groups = {UpdateGroup.class,AddGroup.class})   //至少包含一个字符
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotBlank(message = "新增品牌信息必须携带logo",groups = AddGroup.class)
	@URL(message = "logo必须是一个合法地址!",groups = {UpdateGroup.class,AddGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@NotNull(groups = {AddGroup.class,UpdateStatusGroup.class})  //修改状态必须得有状态
	//@Range(min = 0,max = 1,groups = {UpdateGroup.class,AddGroup.class})
	//如果写了0-1之间的小数,那么将会被Integer截取为整数0!!
	@ListValue(vals = {0,1},message = "显示状态只能是整数0或者1",
			groups = {UpdateGroup.class,AddGroup.class, UpdateStatusGroup.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@NotEmpty(message = "新增品牌不能不加检索字母",groups = {AddGroup.class})
	@Pattern(regexp = "^[a-zA-Z]$",message = "检索字母必须是单个小写或者大写字母",groups = {UpdateGroup.class,AddGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(groups = {AddGroup.class})  //Integer不能使用@NotEmpty
	@Min(value = 0,message = "排序字段只能为大于0的整数",groups = {UpdateGroup.class,AddGroup.class})
	private Integer sort;

}
